﻿using log4net.Core;
using log4net.Layout.Pattern;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI.WebControls;

namespace X.LOG.log4net.CustomPatternConverter
{
    /*
     * 
     * 弃用 使用Config.AddCustomPatternConvert由外部导入类型
     * 
     * */
    public class HttpUserIdPatternConverter : PatternLayoutConverter
    {
        protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            var result = string.Empty;
            result = "9527";
            loggingEvent.Properties["userid"] = result;
            writer.Write(result);
        }
    }

    public class HttpUserTypePatternConverter : PatternLayoutConverter
    {
        protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            var result = string.Empty;
            result = "1";
            loggingEvent.Properties["usertype"] = result;
            writer.Write(result);
        }
    }

    public class HttpIPAddressPatternConverter : PatternLayoutConverter
    {
        protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            var result = string.Empty;
            result = "192.168.254.254";
            loggingEvent.Properties["ip"] = result;
            writer.Write(result);
        }
    }
     
    public class HttpTokenPatternConverter : PatternLayoutConverter
    {
        protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            var result = string.Empty;
            result = "ABCDEFGHIJKLMN";
            loggingEvent.Properties["token"] = result;
            writer.Write(result);
        }
    }
}
